package ioperations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOPeration{
    public void work(BookList bookList){
        int currentSize= bookList.getUsedSize();
        if(currentSize== bookList.getBooks().length){
        System.out.println("书架已放满");
        return;
    }
        System.out.println("新增图书...");
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入书名");
        String name= scanner.nextLine();
        System.out.println("请输入作者");
        String author= scanner.nextLine();
        System.out.println("请输入书的价格");
        int price=scanner.nextInt();
        System.out.println("请输入书的类型");
        String type=scanner.nextLine();
        Book book=new Book(name,author,price,type);
        bookList.setBook(currentSize,book);
        bookList.setUsedSize(currentSize+1);
        System.out.println("插入成功");
    }
}
